package com.tanhua.model.vo;

import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.Movement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

/**
 * @Description：test
 * @Create by： 张会豪
 * @Date：2021/11/7 11:03
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PeachblossomVo {

    private Long id;// 用户id
    private String avatar;//头像
    private String nickname;//昵称
    private String gender;//性别 man woman
    private Integer age;//年龄
    private String soundUrl;//语音地址
    private Integer remainingTimes;//剩余次数

    public static PeachblossomVo init(UserInfo userInfo, Movement movement) {
        PeachblossomVo vo = new PeachblossomVo();
        //copy用户属性
        BeanUtils.copyProperties(userInfo, vo);
        //设置id、soundUrl属性值
        vo.setId(Long.valueOf(userInfo.getId().toString()));
        if (movement.getMedias() != null) {
            vo.setSoundUrl(movement.getMedias().toString());
        }
        return vo;
    }
}
